package com.wildfire.controller;


import com.wildfire.web.Result;
import com.wildfire.service.BasicService;
import com.wildfire.service.UserService;
import com.wildfire.vo.UserLoginReq;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


/**
 * Controller模板
 *
 * @author zwxu5
 */
@Api(tags = "基础功能")
@RestController
@Slf4j
@RequestMapping("/system")
public class SystemController {
    @Autowired
    private UserService userService;
    @Autowired
    private BasicService basicService;

    @GetMapping("/401")
    public ResponseEntity<Result> unLogin() {
        return ResponseEntity.ok(Result.success("需要登陆"));
    }

    @GetMapping("/403")
    public ResponseEntity<Result> unAuth() {
        return ResponseEntity.ok(Result.success("需要授权"));
    }


    @PostMapping("/userLogin")
    public ResponseEntity<Result> userLogin(@RequestBody UserLoginReq userLoginReq) {
        return ResponseEntity.ok(Result.success(userService.userLogin(userLoginReq)));
    }

    @GetMapping("/userLogout")
    public ResponseEntity<Result> userLogout() {
        userService.userLogout();
        return ResponseEntity.ok(Result.success(null));
    }

    @GetMapping("/getAppRouter")
    public ResponseEntity<Result> getAppRouter() {
        return ResponseEntity.ok(Result.success(basicService.getAppRouter()));
    }


}
